package cc.beup.common.util;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @Author: Byron Bai
 * @Date: 2021/4/18 20:13
 * @Description:
 */
public class ThrowableUtil {

    private ThrowableUtil() {
    }

    /**
     * 把异常信息转字符串
     *
     * @param e 异常
     * @Author: xuye
     * @Date: 2021/4/18 20:13
     */
    public static String getExceptionToString(Throwable e) {
        if (e == null) {
            return "";
        }
        StringWriter stringWriter = new StringWriter();
        e.printStackTrace(new PrintWriter(stringWriter));
        return stringWriter.toString();
    }
}
